#ifndef __DJI_Transform_H__
#define __DJI_Transform_H__

#include "main.h"
#include "userCan.h"
#include <stdbool.h>

typedef struct DJI_Handle DJI_HandleTypeDef;

struct DJI_pf
{
	void (*currentDutyMode)(DJI_HandleTypeDef* hdji, float CurrentDuty);
	void (*speedMode)(DJI_HandleTypeDef* hdji, float Speed, float CurrentDutyLimit);
	void (*posMode)(DJI_HandleTypeDef* hdji, float Pos, float SpeedDutyLimit, float CurrentDutyLimit); 
	uint8_t (*getPos)(DJI_HandleTypeDef* hdji, float *pos);
	uint8_t (*getSpeed)(DJI_HandleTypeDef* hdji, float *speed);
	void (*setOrigin)(DJI_HandleTypeDef* hdji);
	void (*clearCount)(DJI_HandleTypeDef* hdji);
};

typedef struct DJI_Status
{
	UserCAN_HandleTypeDef *hcan;
    uint8_t ID;
    float speed;
    float posation;
	bool posRxFlag;
	bool speedRxFlag;
}DJI_Status;

struct DJI_Handle
{
	DJI_Status status;
	struct DJI_pf *pf;
	//gear_ratio should be equal to "DJI -> PID Controllers -> Position Angle Devision"
	//减速比应该等于 "DJI -> PID Controllers -> Position Angle Devision"
};


void DJI_Init(DJI_HandleTypeDef *hdji, UserCAN_HandleTypeDef *hcan, uint8_t ID);
void DJI_RxInit(uint8_t DJINum, DJI_HandleTypeDef **DJIArray);
uint8_t DJI_Analysis(user_FDCAN_Rx_Struct *FDCAN_Rx_struct);


#endif 

